<!--
 * @name: 商家列表
 * @version: 1.1.1
 * @Author: 刘大可
 * @Date: 2022-07-19 12:01:38
 * @LastEditors: 刘大可
 * @LastEditTime: 2022-11-29 19:22:56
-->
<template>
    <view>
        <view class="quan margin">
            <view class="flex tit">
                <image src="/static/icon/shop.png" mode="scaleToFill" />
                <!-- 商家推荐 -->
                {{title}}
                <view class="all" @click="goStore('/gc_school/pages/canteen/canteen')">更多+</view>
            </view>
        </view>
        <view class="store_list" v-if="schoolInfo.store.length>0">
            <!-- <block v-for="(item,index) in schoolInfo.store" :key="index"> -->
            <block v-for="(item,index) in storeList" :key="index">
                <view class="store margin-lr margin-bottom flex" :class="title=='商家列表'?'pd':''" v-if="title=='商家推荐'||(title=='商家列表'&&index>2)"
                    @click="goStore('/gc_school/pages/foold/foold?id=' + item.business_id)">
                    <image class="main_img"
                        :src="(item.business_image == '' || item.business_image == 'undefined/undefined') ? ( fileUrl+'empty.jpg') : item.business_image"
                        mode="" />
                    <view class="store_info padding">
                        <view class="tit">{{ item.business_name }}</view>
                        <image class="store_close" v-if="!item.is_open" src="/static/icon/store_closes.png" mode="" />
                        <!-- {{item.start_time.split(":")[0]*60+item.start_time.split(":")[0]*1>date.date("h")*60+date.date("i")*1&&date.date("h")*60+date.date("i")*1}}
                {{item.end_time.split(":")[0]*60+item.end_time.split(":")[0]*1}}
                {{date.date("h")*60+date.date("i")*1}} -->
                        <view class="flex margin-top-xs">
                            <!-- <view class="fen">4.6分</view> -->
                            <view class="sale">已售:{{ item.sale_num }}</view>
                            <!-- <view class="time">45分钟</view> -->
                            <view class="mi" style="margin-left:auto;">{{ item.juli }}km</view>
                        </view>
                        <view class="tags flex margin-top-sm">
                            <view class="typenei" v-if="item.type == 1">校内</view>
                            <view class="typewai" v-else>校外</view>
                            <view class="tag">起送￥{{ item.starting_fee }}</view>
                            <!-- <view class="tag">配送￥0.9</view> -->
                        </view>

                    </view>
                </view>

            </block>
            <view class="all col" @click="nextPage">
                {{ content }}
            </view>
              
        </view>

    </view>
</template>

<script>
var app = getApp();
export default {
    data() {
        return {
            sys:{},
            authData:{},
            storeList:[],
            page:1,
            content: "查看更多"
        }
    },
    props: {
       
        schoolInfo: {
            type: [Object, Array, String],
            default() {
                return {};
            }
        },
        title: {
            type: String,
            default() {
                return "";
            }
        }

    },
    created() {
        this.initData(this.page)
       
    },
    methods: {
        initData(page){
            var self = this;
            app.globalData.util.request({
                url: 'School/stotelist',
                data: {
                    latitude: uni.getStorageSync('latitude'),
                    longitude: uni.getStorageSync('longitude'),
                    // ...localtion,
                    s_id: this.schoolInfo.s_id,
                    page,
                    limit:10,
                    // show_type: 1
                },

                success:(res)=> {
                    console.log(res.data.data);
                    if (res.data.data) {
                        self.page = page
                        self.storeList = page == 1 ? res.data.data:[
                            ...self.storeList,
                            ...res.data.data
                        ]
                        return
                    }
                    this.content = "没有更多了~"
                    this.tips.tips(this.content)
                   
                    // self.getOrderData()
                    // self.getHistoryList()
                    // self.getRank()
                }
            });
        },
        nextPage(){
            this.initData(this.page+1)

        },
        goStore(e) {
            try {
                uni.setStorageSync('module_id', this.schoolInfo.default_store_module.id)
            } catch (error) {

            }
            this.go(e)
        }
    }
}
</script>
<style lang="scss">
.pd{
        padding:20rpx 0rpx 20rpx 30rpx !important;
        .store_info {
            width: 310rpx;
        }
    }

.all {
    font-size: 32rpx;
    text-align: center;
    font-weight: 700;
    color: #999;
}
   
</style>